package com.fang.security.controller;

import com.fang.security.common.exception.RException;
import com.fang.security.common.result.JsonResult;
import com.fang.security.service.SysUserService;
import com.fang.security.utils.JWTUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description
 * @Author Bernie
 * @Date 2024/4/24 15:40
 **/
@RestController
@RequestMapping("/common")
public class CommonController {

    @Resource
    SysUserService sysUserService;

    @GetMapping("/test")
    public JsonResult test() {
        return JsonResult.success("hello world");
    }


    @GetMapping("/testToken")
    public JsonResult testToken(@RequestParam String token) throws RException {
        String userId = JWTUtil.getUserId(token);
        System.out.println(userId);
        return JsonResult.success("hello world, " + userId);
    }
}
